set(procect_name bm_openssl)
project (${procect_name})

# boost
# set(BOOST_ROOT /home/bm/third_libs/boost_1_77_0)
find_package( Boost REQUIRED)
if(NOT Boost_FOUND)
    message("Not found Boost")
endif()

message(STATUS "boost include path: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIB_VERSION: ${Boost_LIB_VERSION}.")

FILE (GLOB ALL_SOURCES "*.cpp" "*.c" )
FILE (GLOB ALL_INCLUDES "*.hpp" "*.h" )
# aux_source_directory(. DIR_SRCS)
add_library(${procect_name} STATIC ${ALL_INCLUDES} ${ALL_SOURCES})

# if(LOCAL_TEST)
# set(OPENSSL_ROOT "/home/bm/third_libs/local/openssl-1.1.1j")
# else()
# set(OPENSSL_ROOT "/home/bm/third_libs/armv7hf/openssl-1.1.1j")
# endif()

# must build and install the openssl if not install into /usr/local/ or /usr/ directory
# must set(OPENSSL_ROOT ${dir}) or command line use -D OPENSSL_ROOT=${dir}
target_include_directories(${procect_name} PUBLIC "${OPENSSL_ROOT}/include" ${Boost_INCLUDE_DIRS})
target_link_directories(${procect_name} PUBLIC "${OPENSSL_ROOT}/lib")

target_link_libraries(${procect_name} PUBLIC crypto ssl)
if(MSVC)
  # Force to always compile with W4
	if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
		string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
	else()
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
	endif()

	if(IMPORT_DLL)
		ADD_DEFINITIONS(-D_AFXDLL)#如果使用动态库的MFC，则加上_AFXDLL
	endif(IMPORT_DLL)
	#SET(CMAKE_MFC_FLAG 1)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  # Update if necessary
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
endif()


add_executable(bm_openssl_test main.cpp bm_openssl.cpp)
target_include_directories(bm_openssl_test PUBLIC "${OPENSSL_ROOT}/include" ${Boost_INCLUDE_DIRS})
target_link_directories(bm_openssl_test PUBLIC "${OPENSSL_ROOT}/lib")
target_link_libraries(bm_openssl_test PUBLIC crypto)
